﻿<UserControl x:Class="openPDC.UI.UserControls.InputWizardUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"             
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" d:DesignHeight="650" d:DesignWidth="850"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation"             
             xmlns:tsfBinding="clr-namespace:GSF.TimeSeries.UI.Binding;assembly=GSF.TimeSeries.UI"
             Background="Transparent">
    
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/CommonResource.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <StackPanel x:Name="StackPanelRoot" Orientation="Vertical">

        <StackPanel.Resources>
            <CollectionViewSource Source="{Binding Path=CompanyLookupList}" x:Key="CompanyLookupList"/>
            <CollectionViewSource Source="{Binding Path=HistorianLookupList}" x:Key="HistorianLookupList"/>
            <CollectionViewSource Source="{Binding Path=InterconnectionLookupList}" x:Key="InterconnectionLookupList"/>
            <CollectionViewSource Source="{Binding Path=ProtocolLookupList}" x:Key="ProtocolLookupList"/>
            <CollectionViewSource Source="{Binding Path=VendorDeviceLookupList}" x:Key="VendorDeviceLookupList"/>
        </StackPanel.Resources>

        <Expander x:Name="ExpanderStep1" IsExpanded="True" Header="Step 1: Configure Connection Settings" Expanded="ExpanderStep1_Expanded">
            <Grid HorizontalAlignment="Center" IsEnabled="{Binding NewDeviceConfiguration}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="3*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0" Grid.Column="1" Text="Select PMU Connection File (from PMU Connection Tester)" HorizontalAlignment="Left"/>
                <TextBlock Grid.Row="1" Grid.Column="0" Text="Connection File" />
                <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1">
                    <TextBox Text="{tsfBinding:Column Path=DataContext.ConnectionFileName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}" 
                             Width="{StaticResource XXXLargeItemSize}" />
                    <Button Command="{Binding Path=DataContext.BrowseConnectionFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}" 
                            ToolTip="Browse to connection file" Width="Auto">
                        <Button.Template>
                            <ControlTemplate>
                                <Image Source="/GSF.TimeSeries.UI;component/images/Folder.png" Height="24" Width="24" />
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                </StackPanel>

                <TextBlock Text="OR" Grid.Row="2" Grid.Column="1" FontWeight="Bold" FontSize="{StaticResource LargeTextSize}" HorizontalAlignment="Center" />

                <TextBlock Grid.Row="3" Grid.Column="0" Text="Connection String" VerticalAlignment="Top"/>
                <StackPanel Orientation="Vertical" Grid.Row="3" Grid.Column="1">
                    <StackPanel Orientation="Horizontal">
                        <TextBox Text="{tsfBinding:Column Path=DataContext.ConnectionString, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=3}}"  Width="{StaticResource XXXLargeItemSize}" Height="{StaticResource XSmallItemSize}" TextWrapping="Wrap" />
                        <Button Command="{Binding Path=DataContext.BuildConnectionStringCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}"
                            VerticalAlignment="Top" ToolTip="Build connection string" Width="Auto">
                            <Button.Template>
                                <ControlTemplate>
                                    <Image Source="/GSF.TimeSeries.UI;component/images/Plus.png" Height="24" Width="24" />
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                    </StackPanel>
                    <TextBlock Text="Connection information is relative to the openPDC node." FontStyle="Italic" HorizontalAlignment="Left" />
                </StackPanel>

                <TextBlock Grid.Row="4" Grid.Column="0" Text="Alternate Command Channel" TextWrapping="Wrap" VerticalAlignment="Top"/>
                <StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="1">
                    <TextBox Text="{tsfBinding:Column Path=DataContext.AlternateCommandChannel, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}"  Width="{StaticResource XXXLargeItemSize}" Height="{StaticResource XSmallItemSize}" TextWrapping="Wrap" />
                    <Button Command="{Binding Path=DataContext.BuildAlternateCommandChannelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}"
                            VerticalAlignment="Top" ToolTip="Build alternate command channel" Width="Auto">
                        <Button.Template>
                            <ControlTemplate>
                                <Image Source="/GSF.TimeSeries.UI;component/images/Plus.png" Height="24" Width="24" />
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                </StackPanel>

                <Border Grid.Row="5" Grid.Column="1" BorderThickness="1" Margin="2,20,2,20" BorderBrush="#FF333333" />

                <TextBlock Grid.Row="6" Grid.Column="0" Text="Device ID Code"/>
                <TextBox Text="{tsfBinding:Column Path=DataContext.AccessID, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=1}}"  Grid.Row="6" Grid.Column="1" Width="{StaticResource XXSmallItemSize}" />

                <TextBlock Grid.Row="7" Grid.Column="0" Text="Device Protocol" />
                <ComboBox Grid.Row="7" Grid.Column="1" ItemsSource="{Binding Source={StaticResource ProtocolLookupList}}" DisplayMemberPath="Value"
                      SelectedItem="{tsfBinding:Column Path=ProtocolID, Converter={StaticResource DictionaryToKeyValuePairConverter}, ConverterParameter={StaticResource ProtocolLookupList}}"/>

                <TextBlock Grid.Row="8" Grid.Column="0" Text="Select INI File"
                           Visibility="{Binding Path=DataContext.ProtocolIsBpaPdcStream, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel}, Converter={StaticResource ObjectToVisibilityConverter}}"/>
                <StackPanel Orientation="Horizontal" Grid.Row="8" Grid.Column="1"
                            Visibility="{Binding Path=DataContext.ProtocolIsBpaPdcStream, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel}, Converter={StaticResource ObjectToVisibilityConverter}}">
                    <TextBox Text="{tsfBinding:Column Path=DataContext.IniFileName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}"  Width="{StaticResource XXXLargeItemSize}" />
                    <Button Command="{Binding Path=DataContext.BrowseIniFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}"
                        Content=" .. " ToolTip="Browse to ini file" Width="Auto"/>
                </StackPanel>
            </Grid>
        </Expander>

        <Expander x:Name="ExpanderStep2" IsExpanded="False" Header="Step 2: Select Device Configuration Settings" Expanded="ExpanderStep2_Expanded">
            <Grid HorizontalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="3*" />
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="3*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <StackPanel Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="3" Orientation="Horizontal">
                    <Button x:Name="ButtonRequestConfiguration" Content="Request Configuration" Width="175" HorizontalAlignment="Left"
                            Command="{Binding Path=DataContext.RequestConfigurationCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}"/>
                    <TextBlock Text="Request could take up to 60 seconds to complete for UDP only streams." HorizontalAlignment="Left" Margin="0" FontStyle="Italic" />
                </StackPanel>

                <TextBlock Text="OR" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" FontWeight="Bold" FontSize="{StaticResource LargeTextSize}" HorizontalAlignment="Center" Margin="0"/>

                <TextBlock Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Text="Select XML Configuration File (from PMU Connection Tester)" HorizontalAlignment="Left"/>

                <TextBlock Grid.Row="3" Grid.Column="0" Text="Configuration File" />
                <StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3">
                    <TextBox Text="{tsfBinding:Column Path=DataContext.ConfigurationFileName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}"  Width="{StaticResource XXXLargeItemSize}" />
                    <Button Command="{Binding Path=DataContext.BrowseConfigurationFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}"
                            ToolTip="Browse to configuration file" Width="Auto">
                        <Button.Template>
                            <ControlTemplate>
                                <Image Source="/GSF.TimeSeries.UI;component/images/Folder.png" Height="24" Width="24" />
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                </StackPanel>

                <TextBlock Text="OR" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" FontWeight="Bold" FontSize="{StaticResource LargeTextSize}" HorizontalAlignment="Center" Margin="0"/>

                <Button Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="3" Content="Edit Configuration" HorizontalAlignment="Left" Width="175" 
                       Command="{Binding Path=DataContext.ManualConfigurationCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel}}" />

                <StackPanel Orientation="Horizontal" x:Name="StackPanelSummary" Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="3">
                    <Button Content="Save Configuration" Width="175" HorizontalAlignment="Left"
                            Command="{Binding Path=DataContext.SaveConfigurationFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}"/>
                    <TextBlock Text="{tsfBinding:Column Path=DataContext.ConfigurationSummary, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}" Foreground="#FF095188" Width="Auto" Height="Auto"/>
                </StackPanel>

                <Border Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="3" BorderThickness="1" Margin="2" BorderBrush="#FF333333" />

                <CheckBox x:Name="CheckBoxConnectToConcentrator" IsChecked="{tsfBinding:Column Path=DataContext.ConnectToConcentrator, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=1}}"  Content="Connection is to Concentrator" FontWeight="Bold" Grid.Row="8" Grid.Column="1" Grid.ColumnSpan="3" />

                <TextBlock Grid.Row="9" Grid.Column="0" Text="PDC Acronym" Visibility="{Binding ElementName=CheckBoxConnectToConcentrator, Path=IsChecked, Converter={StaticResource ObjectToVisibilityConverter}}"/>
                <StackPanel Orientation="Horizontal" Grid.Row="9" Grid.Column="1" Grid.ColumnSpan="3" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="2"
                            Visibility="{Binding ElementName=CheckBoxConnectToConcentrator, Path=IsChecked, Converter={StaticResource ObjectToVisibilityConverter}}">
                    <TextBox Text="{tsfBinding:Column Path=DataContext.PdcAcronym, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}"  Width="{StaticResource SmallItemSize}" />
                    <TextBlock Text="{tsfBinding:Column Path=DataContext.PdcMessage, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}" Width="Auto" TextWrapping="Wrap"/>
                </StackPanel>

                <TextBlock Grid.Row="10" Grid.Column="0" Text="PDC Name" Visibility="{Binding ElementName=CheckBoxConnectToConcentrator, Path=IsChecked, Converter={StaticResource ObjectToVisibilityConverter}}"/>
                <TextBox Text="{tsfBinding:Column Path=DataContext.PdcName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=1}}" Grid.Row="10" Grid.Column="1" Grid.ColumnSpan="3" 
                         Visibility="{Binding ElementName=CheckBoxConnectToConcentrator, Path=IsChecked, Converter={StaticResource ObjectToVisibilityConverter}}"/>

                <TextBlock Grid.Row="11" Grid.Column="0" Text="PDC Device Vendor" Visibility="{Binding ElementName=CheckBoxConnectToConcentrator, Path=IsChecked, Converter={StaticResource ObjectToVisibilityConverter}}"/>
                <ComboBox Grid.Row="11" Grid.Column="1" ItemsSource="{Binding Source={StaticResource VendorDeviceLookupList}}" DisplayMemberPath="Value"
                      Visibility="{Binding ElementName=CheckBoxConnectToConcentrator, Path=IsChecked, Converter={StaticResource ObjectToVisibilityConverter}}"
                      SelectedItem="{tsfBinding:Column Path=DataContext.PdcVendorDeviceID, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=1}, Converter={StaticResource DictionaryToKeyValuePairConverter}, ConverterParameter={StaticResource VendorDeviceLookupList}}"/>

                <Border Grid.Row="12" Grid.Column="1" Grid.ColumnSpan="3" BorderThickness="1" Margin="2" BorderBrush="#FF333333" />

                <TextBlock Grid.Row="13" Grid.Column="0" Text="Company"/>
                <ComboBox Grid.Row="13" Grid.Column="1" ItemsSource="{Binding Source={StaticResource CompanyLookupList}}" DisplayMemberPath="Value"
                      SelectedItem="{tsfBinding:Column Path=DataContext.CompanyID, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=1}, Converter={StaticResource DictionaryToKeyValuePairConverter}, ConverterParameter={StaticResource CompanyLookupList}}"/>

                <TextBlock Grid.Row="13" Grid.Column="2" Text="Historian"/>
                <ComboBox Grid.Row="13" Grid.Column="3" ItemsSource="{Binding Source={StaticResource HistorianLookupList}}" DisplayMemberPath="Value"
                      SelectedItem="{tsfBinding:Column Path=DataContext.HistorianID, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=1},
                                    Converter={StaticResource DictionaryToKeyValuePairConverter}, ConverterParameter={StaticResource HistorianLookupList}}"/>
                <TextBlock Grid.Row="14" Grid.Column="0" Text="Interconnection"/>
                <ComboBox Grid.Row="14" Grid.Column="1" ItemsSource="{Binding Source={StaticResource InterconnectionLookupList}}" DisplayMemberPath="Value"
                      SelectedItem="{tsfBinding:Column Path=DataContext.InterconnectionID, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=1}, 
                                    Converter={StaticResource DictionaryToKeyValuePairConverter}, ConverterParameter={StaticResource InterconnectionLookupList}}"/>

            </Grid>
        </Expander>

        <Expander x:Name="ExpanderStep3" IsExpanded="False" Expanded="ExpanderStep3_Expanded">

            <Expander.HeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Step 3: Select Devices to Configure" Margin="0,0,250,0" />
                        <StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=ExpanderStep3, Path=IsExpanded, Converter={StaticResource ObjectToVisibilityConverter}}">
                            <TextBlock Background="#FF2EB30D" Foreground="White" Text="*" FontWeight="Bold" TextAlignment="Center" Width="20"/>
                            <TextBlock Foreground="Red" Text=" Device acronym already exists in the database." />
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </Expander.HeaderTemplate>


            <!--<ScrollViewer Height="400">-->
                
                <sdk:DataGrid x:Name="DataGridDevices" ItemsSource="{tsfBinding:Column Path=DataContext.ItemsSource, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=1}}"
                          RowDetailsVisibilityMode="VisibleWhenSelected"  Height="500" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                

                <sdk:DataGrid.Columns>
                        <!--<sdk:DataGridCheckBoxColumn Width="*" Binding="{tsfBinding:Column Path=Include}" CellStyle="{StaticResource CenterAlignCellStyle}"--> 
                    <sdk:DataGridTemplateColumn Width="*">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox IsChecked="{tsfBinding:Column Path=Include}" Checked="CheckBoxDevice_Checked" Unchecked="CheckBoxDevice_Unchecked" HorizontalAlignment="Center" Margin="0" />
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                        <sdk:DataGridTemplateColumn.HeaderTemplate>
                            <DataTemplate>
                                <CheckBox IsChecked="True" Checked="CheckBoxAll_Checked" Unchecked="CheckBoxAll_Unchecked"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.HeaderTemplate>
                    </sdk:DataGridTemplateColumn>

                    <sdk:DataGridTemplateColumn Header="Acronym" Width="4*">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" Background="{tsfBinding:Column Path=StatusColor, Converter={StaticResource StringToStatusColorConverter}}">
                                        <TextBox Text="{tsfBinding:Column Path=Acronym}" Margin="25,0,0,0" Width="{StaticResource ItemSize}" MaxLength="200"/>
                                    <TextBlock Text="*" Foreground="White" FontWeight="Bold" Margin="2"
                                               Visibility="{tsfBinding:Column Path=Existing, Converter={StaticResource ObjectToVisibilityConverter}}"/>
                                </StackPanel>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Name" Width="4*">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>                                
                                <TextBox Text="{tsfBinding:Column Path=Name}" Margin="0" Width="{StaticResource ItemSize}" MaxLength="200"/>                                                                        
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="Longitude" Width="2*">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Text="{tsfBinding:Column Path=Longitude}" Margin="0" Width="{StaticResource XSmallItemSize}"/>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="Latitude" Width="2*">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Text="{tsfBinding:Column Path=Latitude}" Margin="0" Width="{StaticResource XSmallItemSize}"/>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Digitals" Width="*">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox Content="{tsfBinding:Column Path=DigitalCount}" IsChecked="{tsfBinding:Column Path=AddDigitals}" Margin="0" HorizontalAlignment="Center"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Analogs" Width="*">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox Content="{tsfBinding:Column Path=AnalogCount}" IsChecked="{tsfBinding:Column Path=AddAnalogs}" Margin="0" HorizontalAlignment="Center"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>

                <sdk:DataGrid.RowDetailsTemplate>
                    <DataTemplate>
                        <sdk:DataGrid ItemsSource="{tsfBinding:Column Path=PhasorList}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden"
                                     Height="Auto" Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=sdk:DataGrid}}">
                            <sdk:DataGrid.Columns>
                                <sdk:DataGridCheckBoxColumn Width="*" Binding="{tsfBinding:Column Path=Include}" CellStyle="{StaticResource CenterAlignCellStyle}"/>
                                    <sdk:DataGridTemplateColumn Header="Label" Width="5*">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{tsfBinding:Column Path=Label}" Margin="0" Width="{StaticResource XXLargeItemSize}" MaxLength="200"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>
                                    <sdk:DataGridTemplateColumn Header="Type" Width="2*">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{tsfBinding:Column Path=Type}" Margin="0" Width="{StaticResource XXXSmallItemSize}" MaxLength="1"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>
                                    <sdk:DataGridTemplateColumn Header="Phase" Width="2*">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{tsfBinding:Column Path=Phase}" Margin="0" Width="{StaticResource XXXSmallItemSize}" MaxLength="1"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>
                            </sdk:DataGrid.Columns>
                        </sdk:DataGrid>
                    </DataTemplate>
                </sdk:DataGrid.RowDetailsTemplate>

            </sdk:DataGrid>

            <!--</ScrollViewer>-->
            
        </Expander>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Button x:Name="ButtonPrevious" Content="Previous" Click="ButtonPrevious_Click" HorizontalAlignment="Left"/>
            <Button x:Name="ButtonNext" Content="Next" Grid.Column="1" Click="ButtonNext_Click" HorizontalAlignment="Right"/>
        </Grid>

        
    </StackPanel>
    
</UserControl>
